package com.wtw.util;

import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

@Slf4j
public class TicketUtil {

    private static final Random r = new Random();
    private static final int BOUND_RED = 33;
    private static final int BOUND_BLUE = 16;
    private static final boolean[] BOOK_BLUE = new boolean[17];

    public static List<Integer> makeTicket() {
        boolean[] bookRed = new boolean[34];
        List<Integer> ans = new ArrayList<>();
        for (int i = 0; i < 6; i++) {
            int num = r.nextInt(BOUND_RED) + 1;
            while (bookRed[num]) {
                num = r.nextInt(BOUND_RED) + 1;
            }
            bookRed[num] = true;
            ans.add(num);
        }

        Collections.sort(ans);
        int blue = r.nextInt(BOUND_BLUE) + 1;
        while(BOOK_BLUE[blue]) {
            blue = r.nextInt(BOUND_BLUE) + 1;
        }
        BOOK_BLUE[blue] = true;
        ans.add(blue);

        log.info("生成彩票：" + ans);
        return ans;
    }

}
